@use "sass:color";

@use "../../vars" as *;

ul.main-menu {
  box-sizing: border-box;
  grid-gap: 1rem;
  list-style: none;
  margin-top: 1rem;
  padding: 0;
  width: 100%;

  &.show {
    display: block;

    @media screen and (min-width: $screen-md) {
      display: flex;
    }
  }

  @media screen and (min-width: $screen-md) {
    align-items: center;
    display: flex;
    justify-content: space-around;
    margin: 0 auto 0 0;
    max-width: 310px;

    li:last-child {
      flex-basis: inherit;
    }

    .submenu.show {
      display: none;
    }

    .menu-toggle {
      display: none;
    }
  }
}

/* Enable hover interaction if javascript is not available */
@media screen and (min-width: $screen-md) {
  ul.main-menu .submenu {
    display: none;
  }

  ul.main-menu .top-level-entry-container {
    &:hover,
    &:focus-within {
      .submenu {
        display: block;
      }
    }
  }

  // This allows keyboard nav to work more predictably on desktop dropdowns.
  .open-on-focus-within {
    &:focus-within {
      .watch-submenu {
        display: flex;
      }

      .submenu {
        display: block;
      }
    }

    .submenu,
    .watch-submenu {
      display: none;
    }
  }
}
